//注意：parent 是 JS 自带的全局对象，可用于操作父页面
var index = parent.layer.getFrameIndex(window.name); //获取窗口索引

// 增加商机信息
function addbusinessOpportunityItems() {
    var name = $('#name').val(); // 商机名字
    var sex = $(".bo-ia-sex[name='sex']:checked").val();//获取当前选中的radio的值
    var zsex = $(".bo-ia-sex[name='sex']").val();//获取所有name='zsex'的对象
    var position = $('#position').val(); // 职位
    var phone = $('#phone').val(); // 手机号码
    var mailbox = $('#mailbox').val(); // 邮箱号码
    var qq = $('#qq').val(); // QQ号码
    var weChat = $('#weChat').val(); // 微信号码
    var provid = $('#provid option:selected').text(); // 省
    var cityid = $('#cityid option:selected').text(); // 市
    var areaid = $('#areaid option:selected').text(); // 区
    var address = $('#address').val(); // 详细地址
    var level = $('#level').val(); // 信息等级
    var state = $('#state').val(); // 跟进状态
    var remarks = $('#remarks').val(); // 备注说明
    var username = $('#username').val(); // 联系人名字
    var fax = $('#fax').val(); // 传真
    var contact = $('#contact').val(); // 经办人
    var zipcode = $('#zipcode').val(); // 邮编
    var website = $('#website').val(); // 网站
    var source = $('#source').val(); // 信息来源
    if(isEmpty(name) || isEmpty(username) || isEmpty(phone) || isEmpty(address)|| isEmpty(website) || !IsURL(website)){
        return;
    }
    $.ajax({
        type: 'POST',
        url: "/signing/addSigningsAll",
        dataType:"json",
        data:{
            name: name,
            sex: sex,
            position: position,
            phone: phone,
            mailbox: mailbox,
            qq: qq,
            weChat: weChat,
            provid: provid,
            cityid: cityid,
            areaid: areaid,
            address: address,
            level: level,
            state: state,
            remarks: remarks,
            username:username,
            fax: fax,
            contact: contact,
            zipcode: zipcode,
            website: website,
            source: source,
        },
        success: function (message) {
            if(message.code==0){
                parent.layer.msg('增加成功!');
                parent.layer.close(index);
                window.parent.datalist(1,20,'','','','');
            }else {
                parent.layer.msg('增加失败请重试！');
            }
        },error: function (message) {
            parent.layer.msg('增加失败请重试！');
        }
    })
}
